package core.controller.cmds;

import core.controller.CommandController;

public class BackCMD implements ICmd {
	CommandController cc;

	public BackCMD(CommandController commandController) {
		this.cc = commandController;
	}

	final String level = "Back";
	ICmd nextCMD;

	@Override
	public void setNextCmd(ICmd nextCmd) {
		this.nextCMD = nextCmd;

	}

	@Override
	public void execute(String cmd) {
		if (cmd.equals("back")) {
			if (cc.getCurrentUser().isAdmin()) {
				cc.setCurrentLevel("Admin");
			}
			else{
				cc.setCurrentLevel("Operator");
			}
		}
		
		if (nextCMD != null) {
			nextCMD.execute(cmd);
		}

	}

	@Override
	public String getInfo() {
		return "back - Returns to the previous menu";

	}

	@Override
	public String getLevel() {
		return this.level;

	}
}
